package org.anachronos.jeep.ui.attach;

import java.util.List;

import org.anachronos.jeep.core.attach.VirtualMachineAttachement;
import org.anachronos.jeep.core.attach.VirtualMachineRemoteControl;
import org.anachronos.jeep.ui.JeepUiPlugin;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.handlers.HandlerUtil;

public class RefreshCommand extends AbstractHandler {

	@Override
	public Object execute(ExecutionEvent event) throws ExecutionException {
		final VirtualMachineAttachementsView vmView = 
			(VirtualMachineAttachementsView) HandlerUtil.getActivePart(event);
		VirtualMachineRemoteControl virtualMachineRemoteControl = 
			JeepUiPlugin.getDefault().getVirtualMachineRemoteControl();
		final List<VirtualMachineAttachement> allVms = virtualMachineRemoteControl.list();
		vmView.setInput(allVms);
		return null;
	}

}
